//
//  DataCell.m
//  HandheldHospital
//
//  Created by zhangchao on 16/3/3.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "DataCell.h"
#import <Masonry.h>

#define kWidth self.contentView.frame.size.width

@implementation DataCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self addViews];
    }
    return self;
}


- (void)addViews
{
    self.contentLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.contentLabel];
    self.contentLabel.font = [UIFont systemFontOfSize:14];
    self.contentLabel.textColor = [UIColor grayColor];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(kWidth * 0.02);
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.3, 30));
    }];
    
    self.contentTF = [[UITextField alloc] init];
    [self.contentView addSubview:self.contentTF];
    self.contentTF.font = [UIFont systemFontOfSize:15];
    self.contentTF.textAlignment = NSTextAlignmentRight;
//    self.contentTF.backgroundColor = [UIColor blueColor];
    [self.contentTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-(kWidth * 0.01));
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.6, 30));
    }];
    
    self.label = [[UILabel alloc] init];
    [self.contentView addSubview:self.label];
    self.label.font = [UIFont systemFontOfSize:15];
    self.label.textAlignment = NSTextAlignmentRight;
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-(kWidth * 0.01));
        make.size.mas_equalTo(CGSizeMake(kWidth * 0.6, 30));
    }];
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"Cell";
    DataCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[DataCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
